﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSConsoleTest
{
    class TestVariableLengthParam : BaseConsoleTest
    {
        public void printDescription()
        {
            Console.WriteLine("--- Variable length param ---");
        }

        public void doTest()
        {
            int result = sum(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
            Console.WriteLine("1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = {0}", result);
        }

        private int sum(params int[] aArgs)
        {
            int sum = 0;

            foreach (int arg in aArgs)
            {
                sum += arg;
            }

            return sum;
        }
    }
}
